package com.mcp_life.module.mcpclientmodules.controller.mcp.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
@RequiredArgsConstructor
@RequestMapping("/MCPLife")
@Slf4j
@RestController

public class MCPWeatherController {
    @Autowired
    private ChatClient MCPchatClient;

    /**
     * MCP生活服务控制器
     * @param userInput
     * @return
     */

    @GetMapping("/ask")
    public Flux<String> fcChat(@RequestParam("prompt") String userInput) {
        log.info("prompt: {}", userInput);
        return MCPchatClient.prompt(userInput).stream().content();
    }
}
